From 86994b49d3ae578a212bdb23ca3b211f9f33cdb9 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 21 Sep 2007 14:29:08 +0000 Subject: [PATCH] merged patch from maemo-gtk which handles failed keynav correctly also 2007-09-21 Michael Natterer * gtk/gtktextview.c (gtk_text_view_move_cursor_internal) (gtk_text_view_move_viewport): merged patch from maemo-gtk which handles failed keynav correctly also when the cursor is invisible. (Tommi Komulainen) svn path=/trunk/; revision=18851 --- gtk/gtktextview.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index bceb8b6403..52fb5a74e5 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -258,7 +258,7 @@ static void gtk_text_view_move_cursor (GtkTextView *text_view, static void gtk_text_view_page_horizontally (GtkTextView *text_view, gint count, gboolean extend_selection); -static void gtk_text_view_move_viewport (GtkTextView *text_view, +static gboolean gtk_text_view_move_viewport (GtkTextView *text_view, GtkScrollStep step, gint count); static void gtk_text_view_set_anchor (GtkTextView *text_view); @@ -4872,8 +4872,10 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view, switch (step) { - case GTK_MOVEMENT_LOGICAL_POSITIONS: case GTK_MOVEMENT_VISUAL_POSITIONS: + leave_direction = count > 0 ? GTK_DIR_RIGHT : GTK_DIR_LEFT; + /* fall through */ + case GTK_MOVEMENT_LOGICAL_POSITIONS: case GTK_MOVEMENT_WORDS: scroll_step = GTK_SCROLL_HORIZONTAL_STEPS; break; @@ -4881,6 +4883,8 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view, scroll_step = GTK_SCROLL_HORIZONTAL_ENDS; break; case GTK_MOVEMENT_DISPLAY_LINES: + leave_direction = count > 0 ? GTK_DIR_DOWN : GTK_DIR_UP; + /* fall through */ case GTK_MOVEMENT_PARAGRAPHS: case GTK_MOVEMENT_PARAGRAPH_ENDS: scroll_step = GTK_SCROLL_STEPS; @@ -4898,8 +4902,16 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view, scroll_step = GTK_SCROLL_PAGES; break; } - - gtk_text_view_move_viewport (text_view, scroll_step, count); + + if (!gtk_text_view_move_viewport (text_view, scroll_step, count)) + { + if (leave_direction != -1 && + !gtk_widget_keynav_failed (GTK_WIDGET (text_view), + leave_direction)) + { + g_signal_emit_by_name (text_view, "move-focus", leave_direction); + } + } return; } @@ -5079,7 +5091,7 @@ gtk_text_view_page_horizontally (GtkTextView *text_view, } -static void +static gboolean gtk_text_view_move_viewport (GtkTextView *text_view, GtkScrollStep step, gint count) @@ -5123,7 +5135,7 @@ gtk_text_view_move_viewport (GtkTextView *text_view, break; } - set_adjustment_clamped (adjustment, adjustment->value + count * increment); + return set_adjustment_clamped (adjustment, adjustment->value + count * increment); } static void -- 2.30.2